package HomeWorkDemo.day03;

import java.io.*;

/**
 * 将当前目录下的所有obj文件获取到，并进行
 * 反序列化后输出每个用户的信息(直接输出反序
 * 列化后的User对象即可)
 * @author yangbin
 *
 */

public class test02 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        File dir=new File(".");
        File[] subs=dir.listFiles(file -> file.isFile());

        for (File sub:subs){
           // FileInputStream fis=new FileInputStream(sub);
            if (sub.getName().endsWith(".obj")){
                FileInputStream fis=new FileInputStream(sub.getName());
                ObjectInputStream ois=new ObjectInputStream(fis);

                User user =(User) ois.readObject();
                System.out.println(user);
                ois.close();
            }

        }

    }

}
